use serde::Deserialize;
use std::fs;
use anyhow::Result;

#[derive(Debug, Deserialize)]
pub struct SplashConfig {
    pub logo: String,
    pub background_color: String,
    pub text_color: String,
    pub press_key_text: String,
}

#[derive(Debug, Deserialize)]
pub struct GameConfig {
    pub name: String,
    pub splash: SplashConfig,
    pub initial_scene: String,
    pub language: String,
    pub asset_dir: Option<String>, // 添加 asset_dir 字段
}

impl GameConfig {
    pub fn from_file(path: &str) -> Result<Self> {
        let content = fs::read_to_string(path)?;
        let config: GameConfig = serde_json::from_str(&content)?;
        Ok(config)
    }
}